const Role = require('../model/RoleModel')
const init = require('../config/db')
const Api = require('../model/ApiModel')
init()
// eslint-disable-next-line no-unused-expressions
!(async function () {
  // const roles = await Role.find()
  await Api.find()
  const roles = await Role.find().populate({
    path: 'apiCheckedKeys',
    match: { _id: { $in: ['61e39f0e0ffc0eb503883798'] } }
  })
  // console.log('🚀 ~ file: test.js ~ line 5 ~ roles', roles)
  const needRoles = roles.filter(r =>
    r.apiCheckedKeys.length > 0
  )
  console.log('🚀 ~ file: test.js ~ line 17 ~ needRoles', needRoles)
})()

// 61e39f0e0ffc0eb503883798
